export const basicTreeData = [
	{
		id: '2-1',
		name: '行政中心2',
		children: [
			{
				id: '2-1-1',
				name: '行政中心2-1-1',
			},
			{
				id: '2-1-2',
				name: '技术中心2-1-2',
			},
			{
				id: '2-1-3',
				name: '运营中心2-1-3',
			},
			{
				id: '2-1-4',
				name: '营销中心2-1-4',
			},
		],
	},
	{
		id: '3-1',
		name: '技术中心3-1',
	},
	{
		id: '4-1',
		name: '运营中心4-1',
		children: [
			{
				id: '4-1-1',
				name: '行政中心4-1-1',
			},
			{
				id: '4-1-2',
				name: '技术中心4-1-2',
			}
		],
	},
	{
		id: '5-1',
		name: '营销中心5-1',
	}
]

export function deepClone(originData) {
	const type = Object.prototype.toString.call(originData)
	let data
	if (type === '[object Array]') {
		data = []
		for (let i = 0; i < originData.length; i++) {
			data.push(deepClone(originData[i]))
		}
	} else if (type === '[object Object]') {
		data = {}
		for (const prop in originData) {
			// eslint-disable-next-line no-prototype-builtins
			if (originData.hasOwnProperty(prop)) {
				// 非继承属性
				data[prop] = deepClone(originData[prop])
			}
		}
	} else {
		data = originData
	}
	return data
}